package com.cat.greedyAlgorithm;

import java.util.List;

/**
 * @author 曲大人的喵
 * @description https://leetcode.cn/problems/maximum-element-sum-of-a-complete-subset-of-indices/
 * @create 2025/10/12 21:09
 * @since JDK17
 */

public class Solution90 {
    public long maximumSum(List<Integer> nums) {
        Integer[] arr = nums.toArray(Integer[]::new);
        long ans = 0;
        int n = arr.length;
        for (int i = 1; i <= n; i++) {
            long sum = 0;
            for (int j = 1; i * j * j <= n; j++) {
                sum += arr[i * j * j - 1];
            }
            ans = Math.max(ans, sum);
        }

        return ans;
    }
}
